local CheckWidgetType = UI.CheckWidgetType
local CheckArgType = UI.CheckArgType
local CheckArgWidget = UI.CheckArgWidget
local MakeAccessor = UI.MakeAccessor

--[[ LayeredRegion @FIXME ]]--
local LayeredRegion = UI.NewWidgetType("LayeredRegion", "LayoutFrame")
UI.objects["LayeredRegion"].virtual = true

LayeredRegion.parameters = {
	vertex_color_r = 1,
	vertex_color_g = 1,
	vertex_color_b = 1,
	vertex_color_a = 1,
	layer = "ARTWORK",
}

local valid_layers = {
	BACKGROUND = true,
	BORDER = true,
	ARTWORK = true,
	OVERLAY = true,
	HIGHLIGHT = true,
}

function LayeredRegion:Initialize(o)
	local t = UI.params[o]
	assert(t)
end

function LayeredRegion.prototype:SetVertexColor(r, g, b, a)
	CheckWidgetType("LayeredRegion:SetVertexColor", self, "LayeredRegion")
	local t = UI.params[self]
	t.vertex_color_r = r
	t.vertex_color_g = g
	t.vertex_color_b = b
	t.vertex_color_a = a or 1
end

function LayeredRegion.prototype:GetVertexColor()
	CheckWidgetType("LayeredRegion:GetVertexColor", self, "LayeredRegion")
	local t = UI.params[self]
	return t.vertex_color_r, t.vertex_color_g, t.vertex_color_b, t.vertex_color_a
end


function LayeredRegion.prototype:SetGradientAlpha(...)
	CheckWidgetType("LayeredRegion:SetGradientAlpha", self, "LayeredRegion")
	--@FIXME
end

function LayeredRegion.prototype:SetDrawLayer(layer)
	CheckWidgetType("LayeredRegion:SetDrawLayer", self, "LayeredRegion")
	CheckArgType("LayeredRegion:SetDrawLayer", 2, "drawLayer", "string", layer)
	if not valid_layers[layer] then
		error(string.format("invalid layer %q in LayeredRegion:SetDrawLayer()", layer))
	end
	UI.params[self].layer = layer
end

MakeAccessor("LayeredRegion", "GetDrawLayer", "layer")
